package com.jingbian.cppccbackend.config;

import com.jingbian.cppccbackend.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 设置拦截的路径
        registry.addInterceptor(loginInterceptor)
//                .addPathPatterns("/admins/**", "/users/**")  // 拦截这些路径
                .excludePathPatterns(                         // 不拦截这些路径
                        "/admins/login",    // 管理员登录
                        "/users/login",     // 用户登录
                        "/users/register",   // 用户注册
                        "/users/getPhoneNumber",
                        "/users/banners/list",
                        "/users/notifications/list",
                        "/users/news/list",
                        "/users/wxLogin"
                );
    }
}
